import math


class gorlin():
    def __init__(self):
        # http://doctor-network.com/public/littletools/265.html
        # http://cals.medlive.cn/?action=show&key=calc-87&ct=discipline&kt=0
        pass

    def calc(self, data):
        """
        Gorlin公式
        """
        CO = float(data['CO'])  # 心输出量  Cardiac output
        HR = int(data['HR'])  # 心率 heart rate
        DFP = float(data['DFP'])  # 舒张充盈期 Diastolic filling period
        MVG = float(data["MVG"])  # 平均瓣膜梯度 Mean valve gradient
        HVT = int(data['HVT'])  # 瓣膜位置二尖瓣、0 ，主动脉瓣、1，三尖瓣、2，肺动脉、3
        if HVT == 0:  # 心瓣膜面积Heart valve area
            K = 37.7
        else:
            K = 44.3
        HVA = round(CO / (K * HR * DFP * math.sqrt(MVG)), 2)
        return {"HVA": HVA}



